// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Analysis;

public sealed partial class KeywordMarkerTokenFilter : ITokenFilter
{
	[JsonInclude, JsonPropertyName("ignore_case")]
	public bool? IgnoreCase { get; set; }
	[JsonInclude, JsonPropertyName("keywords")]
	[SingleOrManyCollectionConverter(typeof(string))]
	public ICollection<string>? Keywords { get; set; }
	[JsonInclude, JsonPropertyName("keywords_path")]
	public string? KeywordsPath { get; set; }
	[JsonInclude, JsonPropertyName("keywords_pattern")]
	public string? KeywordsPattern { get; set; }

	[JsonInclude, JsonPropertyName("type")]
	public string Type => "keyword_marker";

	[JsonInclude, JsonPropertyName("version")]
	public string? Version { get; set; }
}

public sealed partial class KeywordMarkerTokenFilterDescriptor : SerializableDescriptor<KeywordMarkerTokenFilterDescriptor>, IBuildableDescriptor<KeywordMarkerTokenFilter>
{
	internal KeywordMarkerTokenFilterDescriptor(Action<KeywordMarkerTokenFilterDescriptor> configure) => configure.Invoke(this);

	public KeywordMarkerTokenFilterDescriptor() : base()
	{
	}

	private bool? IgnoreCaseValue { get; set; }
	private ICollection<string>? KeywordsValue { get; set; }
	private string? KeywordsPathValue { get; set; }
	private string? KeywordsPatternValue { get; set; }
	private string? VersionValue { get; set; }

	public KeywordMarkerTokenFilterDescriptor IgnoreCase(bool? ignoreCase = true)
	{
		IgnoreCaseValue = ignoreCase;
		return Self;
	}

	public KeywordMarkerTokenFilterDescriptor Keywords(ICollection<string>? keywords)
	{
		KeywordsValue = keywords;
		return Self;
	}

	public KeywordMarkerTokenFilterDescriptor KeywordsPath(string? keywordsPath)
	{
		KeywordsPathValue = keywordsPath;
		return Self;
	}

	public KeywordMarkerTokenFilterDescriptor KeywordsPattern(string? keywordsPattern)
	{
		KeywordsPatternValue = keywordsPattern;
		return Self;
	}

	public KeywordMarkerTokenFilterDescriptor Version(string? version)
	{
		VersionValue = version;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (IgnoreCaseValue.HasValue)
		{
			writer.WritePropertyName("ignore_case");
			writer.WriteBooleanValue(IgnoreCaseValue.Value);
		}

		if (KeywordsValue is not null)
		{
			writer.WritePropertyName("keywords");
			SingleOrManySerializationHelper.Serialize<string>(KeywordsValue, writer, options);
		}

		if (!string.IsNullOrEmpty(KeywordsPathValue))
		{
			writer.WritePropertyName("keywords_path");
			writer.WriteStringValue(KeywordsPathValue);
		}

		if (!string.IsNullOrEmpty(KeywordsPatternValue))
		{
			writer.WritePropertyName("keywords_pattern");
			writer.WriteStringValue(KeywordsPatternValue);
		}

		writer.WritePropertyName("type");
		writer.WriteStringValue("keyword_marker");
		if (!string.IsNullOrEmpty(VersionValue))
		{
			writer.WritePropertyName("version");
			writer.WriteStringValue(VersionValue);
		}

		writer.WriteEndObject();
	}

	KeywordMarkerTokenFilter IBuildableDescriptor<KeywordMarkerTokenFilter>.Build() => new()
	{
		IgnoreCase = IgnoreCaseValue,
		Keywords = KeywordsValue,
		KeywordsPath = KeywordsPathValue,
		KeywordsPattern = KeywordsPatternValue,
		Version = VersionValue
	};
}